﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.OleDb;

namespace BabyShop.DBO
{
    public class User
    {
        public int ID { get; set; }
        public string username { get; set; }
        public string password { get; set; }
        public string email { get; set; }
        public string fullname { get; set; }
        public string address { get; set; }
        public string birthday { get; set; }
        public DateTime created { get; set; }

        public bool isValid()
        {
            string sql = "select count(*) from users where username=@username and password=@password";
            OleDbConnection conn = new OleDbConnection(DB_Provider.conn_str);
            OleDbCommand cmd = new OleDbCommand(sql, conn);
            int ret = 0;
            try
            {
                conn.Open();
                cmd.Parameters.Add("@username", OleDbType.VarChar).Value = username;
                cmd.Parameters.Add("@password", OleDbType.VarChar).Value = password;
                ret = (int)cmd.ExecuteScalar();
            }
            catch (Exception e)
            {
            }
            finally
            {
                conn.Close();
            }
            return ret > 0;
        }
    }
}